<template>
    <div class="sidebar">
        <el-menu
            class="sidebar-el-menu"
            :default-active="onRoutes"
            :collapse="collapse"
            background-color="#324157"
            text-color="#bfcbd9"
            active-text-color="#20a0ff"
            unique-opened
            router
        >
            <template v-for="item in items">
                <template v-if="item.subs">
                    <el-submenu :index="item.index" :key="item.index">
                        <template slot="title">
                            <i :class="item.icon"></i>
                            <span slot="title">{{ item.title }}</span>
                        </template>
                        <template v-for="subItem in item.subs">
                            <el-submenu
                                v-if="subItem.subs"
                                :index="subItem.index"
                                :key="subItem.index"
                            >
                                <template slot="title">{{ subItem.title }}</template>
                                <el-menu-item
                                    v-for="(threeItem,i) in subItem.subs"
                                    :key="i"
                                    :index="threeItem.index"
                                >{{ threeItem.title }}</el-menu-item>
                            </el-submenu>
                            <el-menu-item
                                v-else
                                :index="subItem.index"
                                :key="subItem.index"
                            >{{ subItem.title }}</el-menu-item>
                        </template>
                    </el-submenu>
                </template>
                <template v-else>
                    <el-menu-item :index="item.index" :key="item.index">
                        <i :class="item.icon"></i>
                        <span slot="title">{{ item.title }}</span>
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
import bus from '../common/bus';
export default {
    data() {
        return {
            collapse: false,
            items: [
                {
                    icon: 'el-icon-lx-home',
                    index: 'dashboard',
                    title: '系统首页'
                },
                {
                    icon: 'el-icon-pie-chart',
                    index: '1',
                    title: '漫画番剧统计',
                    subs: [
                        {
                            index: 'comicType',
                            title: '漫画类型统计'
                        },
                        {
                            index: 'animeRating',
                            title: '番剧评分统计'
                        },
                        {
                            index: 'animeCopy',
                            title: '番剧版权统计'
                        }
                    ]
                },
                {
                    icon: 'el-icon-pie-chart',
                    index: '5',
                    title: '平台视频最多用户数据统计',
                    subs: [
                        {
                            index: 'wlsDate',
                            title: '每日发布视频增量'
                        },
                        {
                            index: 'wlsType',
                            title: '发布视频类型'
                        }

                    ]
                },
                {
                    icon: 'el-icon-pie-chart',
                    index: '2',
                    title: '国产动画和番剧对比',
                    subs: [
                        {
                            index: 'billionCompare',
                            title: '播放量破千万、破亿数量对比'
                        },
                        {
                            index: 'overCompare',
                            title: '完结数量对比'
                        },
                        {
                            index: 'scoreCompare',
                            title: '动画番剧综合得分区间对比'
                        },
                        {
                            index: 'guoFirstTen',
                            title: '动画前十排名展示'
                        },
                        {
                            index: 'riFirstTen',
                            title: '番剧前十排名展示'
                        }
                    ]
                },
                {
                    icon: 'el-icon-pie-chart',
                    index: '3',
                    title: '分区综合得分对比',
                    subs: [
                        {
                            index: 'minCompare',
                            title: '最低分对比'
                        },
                        {
                            index: 'midCompare',
                            title: '平均分对比'
                        },
                        {
                            index: 'maxCompare',
                            title: '最高分对比'
                        }
                    ]
                },
                {
                    icon: 'el-icon-pie-chart',
                    index: '4',
                    title: '2021年每周必看统计',
                    subs: [
                        {
                            index: 'typeWeekFirstFifteen',
                            title: '前十五类型统计'
                        },
                        {
                            index: 'viewWeekFistTen',
                            title: '前十播放视频展示'
                        },
                        {
                            index: 'favourWeekFistTen',
                            title: '前十点赞视频展示'
                        },
                        {
                            index: 'coinWeekFistTen',
                            title: '前十投币视频展示'
                        },
                        {
                            index: 'eachWeekTopOne',
                            title: '2021年每期每周必看播放量最高视频展示'
                        },
                        {
                            index: 'intervalWeekView',
                            title: '播放次数区间统计'
                        }

                    ]
                },

                {
                    icon: 'el-icon-pie-chart',
                    index: '6',
                    title: '生活区搞笑区对比',
                    subs: [
                        {
                            index: 'cpFavour',
                            title: '收藏量对比'
                        },
                        {
                            index: 'cpView',
                            title: '播放量对比'
                        },
                        {
                            index: 'cpTongji',
                            title: '播放区间统计'
                        }

                    ]
                },
                {
                    icon: 'el-icon-lx-cascades',
                    index: '7',
                    title: '数据管理',
                    subs: [
                        {
                            index: 'fanjv',
                            title: '番剧数据管理'
                        },
                        {
                            index: 'weekly',
                            title: '每周必看数据管理'
                        },
                        {
                            index: 'gaoxiao',
                            title: '搞笑区数据管理'
                        },
                        {
                            index: 'shenghuo',
                            title: '生活区数据管理'
                        },
                        {
                            index: 'guochan',
                            title: '国产动画数据管理'
                        }
                    ]
                }
            ]
        };
    },
    computed: {
        onRoutes() {
            return this.$route.path.replace('/', '');
        }
    },
    created() {
        // 通过 Event Bus 进行组件间通信，来折叠侧边栏
        bus.$on('collapse', msg => {
            this.collapse = msg;
            bus.$emit('collapse-content', msg);
        });
    }
};
</script>

<style scoped>
.sidebar {
    display: block;
    position: absolute;
    left: 0;
    top: 70px;
    bottom: 0;
    overflow-y: scroll;
}
.sidebar::-webkit-scrollbar {
    width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
    width: 250px;
}
.sidebar > ul {
    height: 100%;
}
</style>
